home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJLSR106.ARJ / PLOTFILE.CC < prev    next >
C/C++ Source or Header  |  1992-03-30  |  3KB  |  131 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988, 1992 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.     converted to use iostream library by Per Bothner (bothner@cygnus.com)
  6.  
  7. This file is part of GNU CC.
  8.  
  9. GNU CC is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY.  No author or distributor
  11. accepts responsibility to anyone for the consequences of using it
  12. or for whether it serves any particular purpose or works at all,
  13. unless he says so in writing.  Refer to the GNU CC General Public
  14. License for full details.
  15.  
  16. Everyone is granted permission to copy, modify and redistribute
  17. GNU CC, but only under the conditions described in the
  18. GNU CC General Public License.   A copy of this license is
  19. supposed to have been given to you along with GNU CC so you
  20. can know your rights and responsibilities.  It should be in a
  21. file named COPYING.  Among other things, the copyright notice
  22. and this notice must be preserved on all copies.  
  23. */
  24.  
  25. #ifdef __GNUG__
  26. #pragma implementation "PlotFile.h"
  27. #endif
  28. #include <PlotFile.h>
  29.  
  30. /*
  31.  PlotFile implementation module
  32. */
  33.  
  34.  
  35. PlotFile& PlotFile:: cmd(char c)
  36.   ofstream::put(c); 
  37.   return *this; 
  38. }
  39.  
  40. PlotFile& PlotFile:: operator<<(const int x)
  41. #if defined(convex)
  42.   ofstream::put((char)(x>>8)); 
  43.   ofstream::put((char)(x&0377)); 
  44. #else
  45.   ofstream::put((char)(x&0377)); 
  46.   ofstream::put((char)(x>>8)); 
  47. #endif
  48.   return *this; 
  49. }
  50.  
  51. PlotFile& PlotFile:: operator<<(const char *s)
  52.   *(ofstream*)this << s;
  53.   return *this;
  54. }
  55.  
  56.  
  57. PlotFile& PlotFile:: arc(const int xi, const int yi,
  58.              const int x0, const int y0,
  59.              const int x1, const int y1)
  60.   return cmd('a') << xi << yi << x0 << y0 << x1 << y1; 
  61. }
  62.  
  63.  
  64. PlotFile& PlotFile:: box(const int x0, const int y0,
  65.              const int x1, const int y1)
  66.   line(x0, y0, x0, y1);
  67.   line(x0, y1, x1, y1);
  68.   line(x1, y1, x1, y0);
  69.   return line(x1, y0, x0, y0);
  70. }
  71.  
  72. PlotFile& PlotFile:: circle(const int x, const int y, const int r)
  73.   return cmd('c') << x << y << r; 
  74. }
  75.  
  76. PlotFile& PlotFile:: cont(const int xi, const int yi)
  77.   return cmd('n') << xi << yi;
  78. }
  79.  
  80. PlotFile& PlotFile:: dot(const int xi, const int yi, const int dx,
  81.              int n, const int* pat)
  82.   cmd('d') << xi << yi << dx << n;
  83.   while (n-- > 0) *this << *pat++;
  84.   return *this; 
  85. }
  86.  
  87. PlotFile& PlotFile:: erase()
  88.   return cmd('e'); 
  89. }
  90.  
  91. PlotFile& PlotFile:: label(const char* s)
  92.   return cmd('t') << s << "\n"; 
  93. }
  94.  
  95. PlotFile& PlotFile:: line(const int x0, const int y0,
  96.               const int x1, const int y1)
  97.   return cmd('l') << x0 << y0 << x1 << y1; 
  98. }
  99.  
  100. PlotFile& PlotFile:: linemod(const char* s)
  101.   return cmd('f') << s << "\n"; 
  102. }
  103.  
  104. PlotFile& PlotFile:: move(const int xi, const int yi)
  105.   return cmd('m') << xi << yi;
  106. }
  107.  
  108. PlotFile& PlotFile:: point(const int xi, const int yi)
  109.   return cmd('p') << xi << yi; 
  110. }
  111.  
  112. PlotFile& PlotFile:: space(const int x0, const int y0,
  113.                const int x1, const int y1)
  114.   return cmd('s') << x0 << y0 << x1 << y1; 
  115. }
  116.